package com.safe.first.common.exception;


import com.safe.first.common.constants.BaseEnum;
import com.safe.first.common.constants.CodeEnum;

/**
 * 强制业务异常必须提供code码，便于统一维护
 *
 * @author Mickey
 * @since 2019.11.24
 */
public class BizException extends RuntimeException {
    private final BaseEnum<?> msg;
    private Object data;
    public BizException(BaseEnum<?> msg){
        super(msg.getName());
        this.msg = msg;
    }

    public BizException(String msg){
        super(msg);
        this.msg = CodeEnum.FAIL;
    }

    public BizException(BaseEnum<?> msg, Object data){
        super(msg.getName());
        this.msg = msg;
        this.data = data;
    }

    public BaseEnum<?> getMsg() {
        return msg;
    }
    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
